package com.lzh.financial.service.impl;

import com.lzh.financial.constant.Constant;
import com.lzh.financial.service.ITokenService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;

/**
 *
 * @author reborn0530
 */
@Service
@Slf4j
public class TokenServiceImpl implements ITokenService {


    @Resource
//    StringRedisTemplate redisTemplate;
     RedisTemplate<String,String> redisTemplate;
    @Override
    public boolean createCaptcha(String deviceId,String code) {
        redisTemplate.opsForValue().set(Constant.CAPTCHAT_CODE+deviceId,code,60, TimeUnit.SECONDS);
        System.out.println(code);
        return true;
    }

    @Override
    public String getCaptchaCode(String deviceId) {
        return  redisTemplate.opsForValue().get(Constant.CAPTCHAT_CODE + deviceId);
    }
}
